<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>配网监控系统</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<link rel="stylesheet" type="text/css"
			href="<s:url value='../css/main.css'/>">
		<link rel="stylesheet" type="text/css"
			href="<s:url value='../jquery-easyui/themes/stategrid/easyui.css'/>">
		<link rel="stylesheet" type="text/css"
			href="<s:url value='../jquery-easyui/themes/icon.css'/>">
		<script type="text/javascript"
			src="<s:url value='../jquery-easyui/jquery-1.7.2.min.js'/>"></script>
		<script type="text/javascript"
			src="<s:url value='../jquery-easyui/jquery.easyui.min.js'/>"></script>
		<script type="text/javascript"
			src="<s:url value='../jquery-easyui/locale/easyui-lang-zh_CN.js'/>"></script>
		<script type="text/javascript"
			src="<s:url value='../js/common/commonUtil.js'/>"></script>
		<script type="text/javascript"
			src="<s:url value='../js/common/datagridCommon.js'/>"></script>

		<style type="text/css">
.queryTable {
	width: 32.5%;
}

.combo {
	width: 200px;
	margin-left: 6px;
	margin-right: 4px;
	color: #888888;
}
</style>

		<script type="text/javascript"><!--
		$(function(){
			var datagridId = "lineDatagrid"; // 数据集对应table的id
			var listUrl = "../archives/showLines.action"; // 请求数据集的action
			var title = "线路信息"; // 数据集的标题
			var columns = [[
					{field: 'lineId', hidden: true},
					{field: 'stationId', hidden: true},
					{field: 'bureauId', hidden: true},
					{field: 'svgId', hidden: true},
					{field: 'svgFilePath', hidden: true},
					{field: 'lineNo', title: '线路编号', width: 10},
					{field: 'lineName', title: '线路名称', width: 35},
					{field: 'stationName', title: '所属供电所', width: 35},
					{field: 'bureauName', title: '所属供电局', width: 20}
				]]; // 数据集的列信息，列标题，对应的内容和宽度
		    
		    /**
		     *编辑参数，新增和编辑共用同一个表单，在编辑操作和新增操作中这些参数是一样的
		     *modalWinId：彈出窗口id
		     *submitBtnId： 提交按鈕id
		     *formId：表單id
		     *msgFlag：請求action，返回消息對應的屬性
		     ***/
		    var editParams = {
    				modalWinId: "addOrEditWin", 
    				submitBtnId: "addOrEditBtn",
    				formId: "form",
    				msgFlag: "msg"
		    	};	
		    	
		    var addParams = {
    				addUrl: "../archives!addOrModifyLine.action"
				};// 新增操作参数，包括新增操作请求地址
		    var modifyParams = {
		    		loadUrl: "../archives/loadLineByPk.action",
		    		identityId: ["lineId"],
		    		modifyUrl: "../archives!addOrModifyLine.action"
		    	};// 修改操作参数，包括修改操作请求地址
		    
		    // 删除操作参数，包括删除操作请求地址，行唯一主键，请求action，返回消息对应的json属性
		    var removeParams = {
		    		removeUrl: "../archives!removeLineById.action", 
    				identityId: "lineId",
    				msgFlag: "msg"
    			};

			/**
			*查询操作参数
			*queryFormId：查询表单id
			*queryBtnId：查询按钮id
			*/
			var queryParams = {
				queryFormId: "queryForm",
				queryBtnId: "queryBtnFunc"
			}
			
			//显示表单
			showDataGrid(datagridId, listUrl, title, columns, editParams, addParams, removeParams, queryParams, modifyParams);
			
			// 级联列表需要配置如下参数，上级id和级联的url
			$("#stationId", "#form").attr("higherCascadeId", "bureauId");
			$("#stationId", "#form").attr("comboboxUrl", "../archives/showStationsBelonged.action");
			
		});
		
		function autoInsertLineName(obj) {
			var filePath = "";
			if(obj)
            {
                //ie
                if (window.navigator.userAgent.indexOf("MSIE")>=1)
                {
                    obj.select();
                    filePath = document.selection.createRange().text;
                }
                //firefox
                else if(window.navigator.userAgent.indexOf("Firefox")>=1)
                {
                    if(obj.files)
                    {
                        filePath = obj.files.item(0).mozFullPath;
                    }
                    filePath = obj.value;
                }
                filePath = obj.value;
            } 
			
			filePath = $("#svgFilePath").val();
			filePath = filePath.split("\\");//这里要将 \ 转义一下
			$("#lineName", $("#form")).val(filePath[filePath.length-1].substr(0, filePath[filePath.length-1].lastIndexOf("\.")));
		}
--></script>
	</head>

	<body>
		<div id="addOrEditWin" class="easyui-window"
			style="padding: 10px; width: 360px; height: 258px;" closed="true"
			maximizable="false" minimizable="false" collapsible="false">
			<div id="formDiv" style="text-align: align;">
				<form id="form" method="post">
					<input type="hidden" id="lineId" name="lineId" />
					<input type="hidden" id="svgId" name="svgId" />
					<table class="editTable">
						<tr>
							<td class="tdText">
								线路编号
							</td>
							<td>
								<input class="easyui-validatebox inputText" type="text"
									id="lineNo" name="lineNo" required="true" />
							</td>
						</tr>
						<tr>
							<td class="tdText">
								线路文件
							</td>
							<td>
								<input class="inputText" type="file" id="svgFilePath"
									name="svgFilePath" required="true" size="18"
									onchange="autoInsertLineName(this)" />
							</td>
						</tr>
						<tr>
							<td class="tdText">
								线路名称
							</td>
							<td>
								<input class="easyui-validatebox inputText" type="text"
									id="lineName" name="lineName" required="true" />
							</td>
						</tr>

						<tr>
							<td class="tdText">
								所属供电局
							</td>
							<td>
								<input id="bureauId" name="bureauId" class="easyui-combobox"
									 style="width: 200px;"
									data-options="mode:'remote',required:true,valueField:'bureauId',textField:'bureauName',url:'../archives/showAllBureaus.action',
									onSelect: function(rec){  
										$('#stationId').combobox('clear');
						            	var url = '../archives/showStationsBelonged.action?bureauId=' + rec.bureauId;  
						            	$('#stationId').combobox('reload', url);  
						        	}">
							</td>
						</tr>
						<tr>
							<td class="tdText">
								所属供电所
							</td>
							<td>
								<input id="stationId" name="stationId" class="easyui-combobox"
									 style="width: 200px;"
									data-options="mode:'remote',required:true,valueField: 'stationId',textField: 'stationName'">
							</td>
						</tr>
						<tr>
							<td colspan="2" align="center">
								<a class="" id="addOrEditBtn" href="javascript:void(0)"></a>
								<a class="easyui-linkbutton" iconCls="icon-cancel"
									id="addOrEditsstn" href="javascript:void(0)"
									onclick="winClose('addOrEditWin')">取消</a>
							</td>
						</tr>
					</table>
				</form>
			</div>
		</div>
		<s:form theme="simple" id="queryForm" cssClass="queryForm">
			<table class="queryTable">
				<tr>
					<td class="tdText">
						线路名称
					</td>
					<td>
						<s:textfield name="lineName" id="lineName" cssClass="inputText"></s:textfield>
					</td>
					<td class="tdQueryBtn" align="center">
						<input type="button" value="查询" class="queryBtn" id="queryBtnFunc" />
					</td>
				</tr>
			</table>
		</s:form>
		<table id="lineDatagrid">
		</table>
	</body>
</html>
